package com.nicy.filter;





import org.apache.commons.io.IOUtils;

import javax.servlet.*;
import java.io.IOException;

public class ReadBodyFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        String requestBody = IOUtils.toString(servletRequest.getInputStream(),"utf-8");
        System.out.println("print request body in filter:" + requestBody);
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
